#ifndef WINDOW4_H
#define WINDOW4_H
#include"bullet2.h"
#include <QMainWindow>
#include<QList>
#include <QMainWindow>
#include "enemy2.h"
#include <QWidget>
#include <QPainter>
#include <QMouseEvent>
#include <QLabel>
#include "towerposition.h"
#include "towerbase1.h"
#include"bullet2.h"
#include <QMainWindow>
#include<QList>
#include <QWidget>
#include "towerposition.h"
#include "towerbase2.h"
#include "mybutton.h"
#include <towerbase2.h>
#include "waypoint.h"
class WayPoint;
class Enemy2;
class bullet2;
class AudioPlayer;
class window4 : public QMainWindow
{
    Q_OBJECT
public:
    explicit window4(QWidget *parent = nullptr);
    void paintEvent( QPaintEvent *);
    void set_tower();
    void addMyObject();
    void getHpDamage(int damage = 1);
    void removedEnemy(Enemy1 *enemy);
    void removedBullet(bullet2 *bullet);
    void addBullet(bullet2 *bullet);
    void awardGold(int gold);
    AudioPlayer* audioPlayer() const;
    QList<Enemy2 *> enemyList() const;

     void addMyObject2();
     void showInfo(QPainter*painter);
    QList<bullet2*>bullet_list;

    void fire();
    void updatescreen();
    void updateScene();
    void loadPos();
    void mousePressEvent(QMouseEvent *event);
    bool ifbuy() const;


    void add_way();
    void Hp_damage(int damage);
    void remove_enemy(Enemy2 *_enemy);
    bool loadwave();
    QList<Enemy2*> enemy_list() const;
    void timeout();
    void remove_bulluet(bullet2 *Bulluet );
    void add_bulluet(bullet2 *_bulluet);
    void awardgold(int gold);
    void show_info(QPainter *painter);
    void do_gameover();

private slots:
    void update_map();
    void update_wave();

private:
    void loadTowerPositions();
    void addWayPoints();
    bool loadWave();
    bool canBuyTower() const;
    void drawWave(QPainter *painter);
    void drawHP(QPainter *painter);
    void drawPlayerGold(QPainter *painter);
    void doGameOver();
    void preLoadWavesInfo();
    int fee = 1000;
    int wave = 20;


    int money=800;

    int						m_waves;
    int						m_playerHp;
    int						m_playrGold;
    bool					m_gameEnded;
    bool					m_gameWin;
    AudioPlayer *			m_audioPlayer;
    QList<QVariant>			m_wavesInfo;


    QList<WayPoint *>		m_wayPointsList;

    QList<bullet2 *>			m_bulletList;
    QList<towerbase2*>towerbase_list;
    QList<TowerPosition> towerPositionsList;
    QList<towerbase2*> towersList;

    QList<waypoint*> waypoint_list;

    QList<Enemy2 *> m_enemyList;
    bool if_game_win=false;
    int base_health=7;
    bool gameEnd=false;
signals:
    void Back();

};

#endif // WINDOW4_H
